import os  
import requests  
from pathlib import Path  
import yaml  

yaml_file_path  = "themes/DoIt2/assets/data/cdn/jsdelivr.yml"

with open(yaml_file_path, 'r') as file:  
    libs = yaml.safe_load(file)  

print(libs['libFiles'])

for key,val in libs['libFiles'].items():
    url = "https://cdn.jsdelivr.net/npm/"+val
    path = "npm/" + os.path.dirname(val)  
    os.makedirs(path, exist_ok=True)
    # print(url)
    # print(path+"/"+os.path.basename(val))
    r = requests.get(url)
    with open("npm/"+val, 'wb') as f:
        f.write(r.content)